home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / PowerPlant / AGA Classes 1.2 / Buttons / LAGADefaultOutline.cp next >
Encoding:
Text File  |  1996-06-30  |  6.4 KB  |  171 lines  |  [TEXT/CWIE]

  1. // ===========================================================================
  2. //    LAGADefaultOutline.cp
  3. // ===========================================================================
  4. //    “Apple Grayscale Appearance” compliant default button outline
  5. //    Copyright © 1996 Chrisoft (Christophe ANDRES)  All rights reserved.
  6. //
  7. //    You may use this source code in any application (commercial, shareware, freeware,
  8. //    postcardware, etc), but not remove this notice (no need to acknowledge the use of
  9. //    this class in the about box)
  10. //    You may not sell this source code in any form. This source code may be placed on 
  11. //    publicly accessable archive sites and source code disks. It may not be placed on 
  12. //    profit archive sites and source code disks without the permission of the author, 
  13. //    Christophe ANDRES.
  14. //    
  15. //        This source code is distributed in the hope that it will be useful,
  16. //        but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. //        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  18. //
  19. //    If you make any change or improvement on this class, please send the improved/changed
  20. //    version to : chrisoft@calva.net or Christophe ANDRES
  21. //                                     20, rue Prosper Mérimée
  22. //                                     67100 STRASBOURG
  23. //                                     FRANCE
  24. //
  25. // ===========================================================================
  26. //    LAGADefaultOutline.h            <- double-click + Command-D to see class declaration
  27. //
  28. //    LAGADefaultOutline is my implementation of the “Apple Grayscale Appearance for System 7.5”
  29. //        default button outline (used by LAGADialogBox)
  30. //
  31. //        This class requires AGAColors.cp to be present in your project
  32. //
  33. //        Version : 1.2
  34. //
  35. //        Change History (most recent first, date in US form : mm/dd/yy):
  36. //
  37. //                        06/30/96    ca        Public release of version 1.2
  38. //                        06/19/96    dj        Dan Johnson <DANJ@CSI.compuserve.com>
  39. //                                                        Added call to StColorPenState::Normalize to avoid odd influence on our colors
  40. //                        06/04/96    ca        Increased version to 1.2
  41. //                        05/15/96    ca        Replaced HasAGAColors by PaneInColor (see note in AGAColors.h)
  42. //                        05/11/96    ca        Increased version to 1.1
  43. //                                                        Replaced UEnvironment::HasFeature(env_SupportsColor) with HasAGAColors
  44. //                                                        Added change history
  45. //                        04/22/96    ca        class made available by Christophe ANDRES <chrisoft@calva.net>
  46. //                                                        (version 1.0)
  47. //
  48. //        To Do:
  49. //
  50.  
  51. #include "LAGADefaultOutline.h"
  52. #include "AGAColors.h"
  53.  
  54. char LAGADefaultOutline::mCorners[4][5][5] =    {
  55.                                                                                                 //    topleft
  56.                                                                                                 {
  57.                                                                                                     { -1, -1, -1, 12,  B },
  58.                                                                                                     { -1, -1,  B,  2,  2 },
  59.                                                                                                     { -1,  B,  2,  2,  5 },
  60.                                                                                                     { 12,  2,  2,  2,  8 },
  61.                                                                                                     {  B,  2,  5,  8, -1 }
  62.                                                                                                 },
  63.                                                                                                 //    topright
  64.                                                                                                 {
  65.                                                                                                     {  B, 12, -1, -1, -1 },
  66.                                                                                                     {  2,  3,  B, -1, -1 },
  67.                                                                                                     {  5,  5,  4,  B, -1 },
  68.                                                                                                     {  8,  5,  5,  7, 12 },
  69.                                                                                                     { -1,  8,  5,  8,  B }
  70.                                                                                                 },
  71.                                                                                                 //    bottomleft
  72.                                                                                                 {
  73.                                                                                                     {  B,  2,  5,  8, -1 },
  74.                                                                                                     { 12,  3,  5,  5,  8 },
  75.                                                                                                     { -1,  B,  4,  5,  5 },
  76.                                                                                                     { -1, -1,  B,  7,  8 },
  77.                                                                                                     { -1, -1, -1, 12,  B }
  78.                                                                                                 },
  79.                                                                                                 //    bottomright
  80.                                                                                                 {
  81.                                                                                                     { -1,  8,  5,  8,  B },
  82.                                                                                                     {  8,  5,  7,  8, 12 },
  83.                                                                                                     {  5,  7,  8,  B, -1 },
  84.                                                                                                     {  8,  8,  B, -1, -1 },
  85.                                                                                                     {  B, 12, -1, -1, -1 }
  86.                                                                                                 }
  87.                                                                                             };
  88.  
  89.  
  90.  
  91. LAGADefaultOutline::LAGADefaultOutline (LPane *inHostPane) : LDefaultOutline (inHostPane)
  92.  
  93. {
  94.     ResizeFrameBy(-2, -2,  false);
  95.     MoveBy(1, 1, true);
  96. }
  97.  
  98. void LAGADefaultOutline::DrawSelf ()
  99.  
  100. {
  101.     StColorPenState outlineColor;                                                                                            //    <06/19/96    dj>
  102.     Rect    frame;
  103.     Boolean hasColor = ::PaneInColor(this);                                                                        //    <05/15/96 ca>
  104.     Boolean bwOutline = !hasColor;
  105.     
  106.     outlineColor.Normalize();                                                                                                    //    <06/19/96    dj>
  107.     if (CalcLocalFrameRect(frame))
  108.         {
  109.             while(true)
  110.                 {
  111.                     ::MoveTo(frame.left + 3, frame.top);
  112.                     ::LineTo(frame.right - 4, frame.top);
  113.                     ::LineTo(frame.right - 1, frame.top + 3);
  114.                     ::LineTo(frame.right - 1, frame.bottom - 4);
  115.                     ::LineTo(frame.right - 4, frame.bottom - 1);
  116.                     ::LineTo(frame.left + 3, frame.bottom - 1);
  117.                     ::LineTo(frame.left, frame.bottom - 4);
  118.                     ::LineTo(frame.left, frame.top + 3);
  119.                     ::LineTo(frame.left + 3, frame.top);
  120.                     if (bwOutline)
  121.                         {
  122.                             ::InsetRect(&frame,1 ,1);
  123.                             bwOutline = false;
  124.                         }
  125.                     else
  126.                         break;
  127.                 }
  128.             
  129.             if (hasColor)
  130.                 {
  131.                     const RGBColor *col = gAGAColorArray;
  132.                     for (int i = 0; i < 5; i++)
  133.                         for (int j = 0; j < 5; j++)
  134.                             {
  135.                                 if (mCorners[0][i][j] != -1)
  136.                                     ::SetCPixel(frame.left + j, frame.top + i, &col[mCorners[0][i][j]]);
  137.                                 if (mCorners[1][i][j] != -1)
  138.                                     ::SetCPixel(frame.right - 5 + j, frame.top + i, &col[mCorners[1][i][j]]);
  139.                                 if (mCorners[2][i][j] != -1)
  140.                                     ::SetCPixel(frame.left + j, frame.bottom - 5 + i, &col[mCorners[2][i][j]]);
  141.                                 if (mCorners[3][i][j] != -1)
  142.                                     ::SetCPixel(frame.right - 5 + j, frame.bottom - 5 + i, &col[mCorners[3][i][j]]);
  143.                             }
  144.                     
  145.                     ::RGBForeColor(&gAGAColorArray[2]);
  146.                     ::MoveTo(frame.left + 1, frame.top + 5);
  147.                     ::LineTo(frame.left + 1, frame.bottom - 6);
  148.                     ::MoveTo(frame.left + 5, frame.top + 1);
  149.                     ::LineTo(frame.right - 6, frame.top + 1);
  150.                     
  151.                     ::RGBForeColor(&gAGAColorArray[5]);
  152.                     ::MoveTo(frame.left + 4, frame.top + 2);
  153.                     ::LineTo(frame.right - 5, frame.top + 2);
  154.                     ::LineTo(frame.right - 3, frame.top + 4);
  155.                     ::LineTo(frame.right - 3, frame.bottom - 5);
  156.                     ::LineTo(frame.right - 5, frame.bottom - 3);
  157.                     ::LineTo(frame.left + 4, frame.bottom - 3);
  158.                     ::LineTo(frame.left + 2, frame.bottom - 5);
  159.                     ::LineTo(frame.left + 2, frame.top + 4);
  160.                     ::LineTo(frame.left + 4, frame.top + 2);
  161.                     
  162.                     ::RGBForeColor(&gAGAColorArray[8]);
  163.                     ::MoveTo(frame.right - 2, frame.top + 5);
  164.                     ::LineTo(frame.right - 2, frame.bottom - 6);
  165.                     ::MoveTo(frame.left + 5, frame.bottom - 2);
  166.                     ::LineTo(frame.right - 6, frame.bottom - 2);
  167.                 }
  168.         }        
  169. }
  170.  
  171.